package com.yowasa.xiuxian.engine.item.danyao;

import com.yowasa.xiuxian.annoations.Item;
import com.yowasa.xiuxian.engine.item.ItemInterface;
import com.yowasa.xiuxian.entity.bo.user.UserBO;
import com.yowasa.xiuxian.entity.enums.ItemTypeEnum;
import com.yowasa.xiuxian.entity.enums.StageEnum;
import com.yowasa.xiuxian.exception.HandlerException;
import com.yowasa.xiuxian.service.helper.UserHelper;
import org.springframework.beans.factory.annotation.Autowired;

@Item(name = "培元丹", type = ItemTypeEnum.DAN_YAO, price = 500)
public class PeiYuanDan implements ItemInterface {
    @Autowired
    private UserHelper userHelper;


    @Override
    public String desc() {
        return "巩固境界 境界处于初期时可以使用，获取一定量的经验，商店少量出售";
    }

    @Override
    public String effect(UserBO userBO) {
        if (userBO.getLevel() >= 30) {
            throw new HandlerException("培元丹只能稳固境界（必须在一个境界初期使用）");
        }
        StageEnum stage = StageEnum.getById(userBO.getStage());
        int exp = stage.getRate() * 500;
        userHelper.addExp(userBO, exp);
        String exMsg = "";
        if (userBO.getLevel() >= 30) {
            exMsg = ",你感觉已经度过了当前境界的初期阶段";
        }
        return "稳固了当前的境界" + exMsg;

    }


}
